//
//  XMGNewViewController.m
//  BuDeJie19
//
//  Created by hjj on 2016/12/3.
//  Copyright © 2016年 hjjuny. All rights reserved.
//

/*
    pch:
 */

#import "XMGNewViewController.h"
#import "UIBarButtonItem+Item.h"
#import "XMGAllViewController.h"
#import "XMGVideoViewController.h"
#import "XMGVoiceViewController.h"
#import "XMGPictureViewController.h"
#import "XMGTextViewController.h"
#import "XMGSubTagViewController.h"
@interface XMGNewViewController ()

@end

@implementation XMGNewViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 添加所有的子控制器:
    [self setupAllChildViewController];
    
    self.view.backgroundColor = [UIColor greenColor];
    // Do any additional setup after loading the view.
    [self setupNavBar];
  
}

- (void)setupAllChildViewController
{
    // 全部
    XMGAllViewController *allVc = [[XMGAllViewController alloc] init];
    allVc.title = @"全部";
    [self addChildViewController:allVc];
    
    // 视频
    XMGVideoViewController *videoVc = [[XMGVideoViewController alloc] init];
    videoVc.title = @"视频";
    [self addChildViewController:videoVc];
    
    // 声音
    XMGVoiceViewController *voiceVc = [[XMGVoiceViewController alloc] init];
    voiceVc.title = @"声音";
    [self addChildViewController:voiceVc];
    
    // 图片
    XMGPictureViewController *pictureVc = [[XMGPictureViewController alloc] init];
    pictureVc.title = @"图片";
    [self addChildViewController:pictureVc];
    
    // 段子
    XMGTextViewController *textVc = [[XMGTextViewController alloc] init];
    textVc.title = @"段子";
    [self addChildViewController:textVc];
}

- (void)setupNavBar
{
    // 设置导航条内容 => 栈顶控制器的navgationItem决定
    self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"MainTitle"]];
    
    // bug:按钮点击范围扩大
    // 不要让按钮扩大点击范围
    // 把按钮包装成UIBarButtonItem就让按钮扩大点击范围
    
    // 左边
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImage:[UIImage imageNamed:@"MainTagSubIcon"] highImage:[UIImage imageNamed:@"MainTagSubIconClick"] target:self action:@selector(subClick)];
    
}

- (void)subClick
{
    XMGSubTagViewController *vc = [[XMGSubTagViewController alloc] init];

    [self.navigationController pushViewController:vc animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
